﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuocTeViet.DO;
using QuocTeViet.BL;
using System.Data;

namespace QuocTeViet.Module
{
    public partial class ucMenuleft_2 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                rptDichVuDataSource();
        }
        protected void rptDichVuDataSource()
        {
            rptDichVu.DataSource = new cmsCategoryBL().SelectByParentID(3, 0);
            rptDichVu.DataBind();

        }
        protected string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
        public string ReturnShowHide(string idshowhide)
        {
            //int i = int.Parse(idshowhide);
            //if (Request.QueryString["ID"] != null)
            //{
            //    string url = Request.Url.AbsolutePath;
            //    url = url.Substring(1, url.Length - 1);
            //    string url1 = url.Replace(".", "/");
            //    string Module = url1.Substring(0, url1.IndexOf("/"));
            //    if (Module.Equals("SanPham"))
            //    {
            //        string id = Request.QueryString["ID"].ToString();
            //        if (id.Equals(i.ToString())) return "show-div";
            //        else
            //        {
            //            cmsLoaiSanPhamDO obj = new cmsLoaiSanPhamDO { LoaiSanPhamID = int.Parse(id) };
            //            obj = new cmsLoaiSanPhamBL().Select(obj);
            //            if (obj.ParentID == i) return "show-div";
            //            else return "hide-div";
            //        }
            //    }
            //    return "hide-div";
            //}
            return "hide-div";
        }

        protected void rptDichVu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = (DataRowView)item.DataItem;
                DataTable dtMenuChild = new cmsCategoryBL().SelectByParentID2(int.Parse(drv["CategoryID"].ToString()), 0);
                Repeater rptMenuChild = (Repeater)item.FindControl("rptChild");
                rptMenuChild.DataSource = dtMenuChild;
                rptMenuChild.DataBind();
            }
        }
    }
}